﻿using System.Data;
using NUnit.Framework;

namespace SchemaInfo.Test
{
    public abstract class TestSchemaBase : TestBase
    {
        protected string _testDatabaseName;
        protected SchemaTestDbUtil _schemaTestDbUtil;

        [TestFixtureSetUp]
        public override void TestFixtureSetup()
        {
            base.TestFixtureSetup();
            _schemaTestDbUtil = CreateSchemaTestDbUtil();
            _testDatabaseName = _schemaTestDbUtil.TestDatabaseName;
            SetupTestDataBase();
        }

        protected abstract SchemaTestDbUtil CreateSchemaTestDbUtil();

        protected virtual IDbConnection CreateDBConnection()
        {
            return _schemaTestDbUtil.CreateDBConnection();
        }

        protected virtual IDbConnection CreateMasterDBConnection()
        {
            return _schemaTestDbUtil.CreateMasterDBConnection();
        }

        protected virtual void SetupTestDataBase()
        {
            CreateTestDatabase();
        }

        protected virtual void CreateTestDatabase()
        {
            _schemaTestDbUtil.CreateTestDatabase();
        }

        protected virtual void ClearDatabase(IDbConnection connection)
        {
            _schemaTestDbUtil.ClearDatabase(connection);
        }

    }
}
